$(function (argument) {

	var dest_id = $('#Hide_DestID').val();

	// dianping pagination
	var articlesWrap = $('.articles-group'),
	pages = $('.pagination li'), 
	max = pages.eq(pages.length - 2).data('page'),
	page = 1, size = 5, hasNext = true, articles,
	articleTmpl = $('#article-template').html();
		
	pages.on('click', function() {
		var _page = ~~$(this).data('page');

		if(!_page && page == max) {
			return;
		}
		
		page = _page || (page ++ > max ? max : page);

		$('.pagination li[data-page='+page+']').addClass('active').siblings().removeClass('active');

		$.get('/api/Destination/GetCommentPagedList/?destid='+dest_id+'&pageindex='+page+'&pagesize='+size, function(data) {
			articles = data.Rows;
			_.each(articles, function(item) {
				var tm = item.DataChangeTime;
				item.DataChangeTime = tm.substring(0, tm.indexOf('T')).replace(/'-'/, '/');
			});
			articlesWrap.html(_.template(articleTmpl, {articles: articles}));
			articlesWrap.parent()[0].scrollIntoView();
		});
	});

});